<template>
  <div style="border:1px solid red">
    <h1>用户管理 湖人总冠军</h1>
    <el-table :data="currentData" border style="width: 100%">
      <el-table-column prop="id" label="账号"></el-table-column>
      <el-table-column prop="password" label="密码"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="email" label="邮箱"></el-table-column>
      <el-table-column prop="call" label="联系方式"></el-table-column>
      <el-table-column prop="location" label="邮寄地址"></el-table-column>
      <el-table-column prop="role" label="身份"></el-table-column>
      <el-table-column prop="state" label="帐号状态"></el-table-column>
      <el-table-column label="操作" width="180">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block" style="position:absolute;bottom:15px">
      <el-pagination
        hide-on-single-page
        layout="prev, pager, next"
        :total="pageNum"
        :page-size="3"
        :pager-count="7"
        @current-change="changePage"
        :current-page="currentPage"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
export default {
  name: "user",
  computed: {
    ...mapState({
      userData: function(state) {
        return this.$store.state.userStore.usersData.data;
      }
    }),
    currentData() {
      let kaishi = (this.currentPage - 1) * 3;
      let jieshu = (this.currentPage - 1) * 3 + 3;
      return this.userData.slice(kaishi, jieshu);
    },
    pageNum() {
      return this.userData.length
    }
  },
  data() {
    return {
      currentPage: 1
    };
  },
  methods: {
    ...mapActions(["getUserData"]),
    changePage(val){
        this.currentPage=val 
    }
  },
  created() {
    console.log(this.$store.state.userStore.usersData,9999)
    this.getUserData();

  }
};
</script>

<style scoped>
</style>